package com.yzy.baselibrary.base.repository

import com.yzy.baselibrary.integration.IRepositoryManager
import com.tencent.mmkv.MMKV
import com.yzy.baselibrary.base.BaseApplication
import io.rx_cache2.internal.RxCache
import org.kodein.di.Kodein
import org.kodein.di.generic.instance

/**
 *description: 本地缓存的数据源基类.
 *@date 2018/10/16 15:22.
 *@author: YinZeYu.
 */
open class BaseLocalDataSource : ILocalDataSource {

  protected var kodein: Kodein = BaseApplication.INSTANCE.kodein

  private val repositoryManager: IRepositoryManager by kodein.instance()

  //键值对缓存
  protected val mmkv: MMKV by kodein.instance()


  //RxCache网络请求缓存
  protected val rxCache: RxCache by kodein.instance()

  /**
   * 获取RxCache的Service
   */
  fun <T> cacheService(service: Class<T>): T =
      repositoryManager.obtainCacheService(service)

}